﻿using DevExpress.XtraEditors;
using SuperMap.Data;
using SuperMap.Sample.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Rail.Start.Viewer
{
    public partial class OpenEngineeringForm : XtraForm
    {
        WorkspaceConnectionInfo m_connectionInfo ;
        public OpenEngineeringForm()
        {
            InitializeComponent();
            GetEngineeringIDs();
        }
        /// <summary>
        /// 存放工程表 id及name
        /// </summary>
        public Dictionary<object, object> m_Pairs = new Dictionary<object, object>();
        /// <summary>
        /// 更新固有路径下可打开项目
        /// </summary>
        public void GetEngineeringIDs()
        {
            m_connectionInfo = new WorkspaceConnectionInfo();
            //工程表 id 列获取
            #region
            string engineer = "sys_project_engineering";
            string sql1 = Commons.MySqlHelper.GetAllField(engineer);
            DataTable dataTable_eng = Commons.MySqlHelper.GetDataTable(sql1, engineer);
            object[] items_eng_id = (from DataRow dr in dataTable_eng.Rows select dr[0]).ToArray();
            object[] items_eng_name = (from DataRow dr in dataTable_eng.Rows select dr[1]).ToArray();
            #endregion

            m_Pairs.Clear();
            for(int i=0;i<items_eng_id.Length;i++)
            {
                m_Pairs.Add(items_eng_name[i], items_eng_id[i]);
            }
            m_ComboBoxEngineer.Items.Clear();
            m_ComboBoxEngineer.Items.AddRange(items_eng_name);
        }
        /// <summary>
        /// 打开按钮
        /// </summary>
        public SimpleButton SimpleButton
        {
            get
            {
                return this.m_SimpleButton;
            }
        }
        /// <summary>
        /// 工程选择下拉列表
        /// </summary>
        public System.Windows.Forms.ComboBox ComboBoxEngineer
        {
            get
            {
                return this.m_ComboBoxEngineer;
            }
        }
    }
}
